package com.wesley.method;

public class Demo05 {
    public static void main(String[] args) {
        //调用可变参数的方法
        printMax(2.1, 3, 50, 60, 100.0);
        printMax(new double[]{1, 2, 3});
    }

    public static void printMax(double... numbers){
        if (numbers.length == 0){
            System.out.println("No argument passed");
            return;
        }

        double result = numbers[0];

        //求最大值排序
        for (int i = 1; i < numbers.length; i++) {
            if (numbers[i] > result){
                result = numbers[i];
            }
        }
        System.out.println("The max value is " + result);
    }
}
